package com.yupi.yuojbackendjudgeservice.judege;


import com.yupi.yuojbackendjudgeservice.judege.strategy.DefaultJudgeStrategy;
import com.yupi.yuojbackendjudgeservice.judege.strategy.JavaLanguageJudgeStrategy;
import com.yupi.yuojbackendjudgeservice.judege.strategy.JudgeContext;
import com.yupi.yuojbackendjudgeservice.judege.strategy.JudgeStrategy;
import org.springframework.stereotype.Service;
import yuojbackendmodel.model.codesandbox.JudgeInfo;
import yuojbackendmodel.model.entity.QuestionSubmit;

/**
 * @Description 判题管理，简化调用(选择策略)
 * @Author JFeng
 * @Date 2023/10/15
 */
@Service
public class JudgeManage {
    JudgeInfo doJudge(JudgeContext judgeContext){
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategy();
        if ("java".equals(language)){
            judgeStrategy = new JavaLanguageJudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
